home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / Clear.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  5.3 KB  |  170 lines

  1. /*
  2. //   (C) COPYRIGHT International Business Machines Corp. 1993
  3. //   All Rights Reserved
  4. //   Licensed Materials - Property of IBM
  5. //   US Government Users Restricted Rights - Use, duplication or
  6. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. //
  8.  
  9. //
  10. // Permission to use, copy, modify, and distribute this software and its
  11. // documentation for any purpose and without fee is hereby granted, provided
  12. // that the above copyright notice appear in all copies and that both that
  13. // copyright notice and this permission notice appear in supporting
  14. // documentation, and that the name of I.B.M. not be used in advertising
  15. // or publicity pertaining to distribution of the software without specific,
  16. // written prior permission. I.B.M. makes no representations about the
  17. // suitability of this software for any purpose.  It is provided "as is"
  18. // without express or implied warranty.
  19. //
  20. // I.B.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  21. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I.B.M.
  22. // BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  23. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  24. // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  25. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. // Author:  John Spitzer, IBM AWS Graphics Systems (Austin)
  28. //
  29. */
  30.  
  31. #include "Clear.h"
  32. #include "ClearX.h"
  33.  
  34. #undef offset
  35. #define offset(v) offsetof(Clear,v)
  36.  
  37. static InfoItem ClearInfo[] = {
  38. #define INC_REASON INFO_ITEM_ARRAY
  39. #include "Clear.h"
  40. #undef INC_REASON
  41. };
  42. #include <malloc.h>
  43.  
  44. ClearPtr new_Clear()
  45. {
  46.     ClearPtr this = (ClearPtr)malloc(sizeof(Clear));
  47.     CheckMalloc(this);
  48.     new_Drawn((DrawnPtr)this);
  49.     SetDefaults((TestPtr)this, ClearInfo);
  50.     this->testType = ClearTest;
  51.     this->usecPixelPrint = " microseconds per pixel in a Clear";
  52.     this->ratePixelPrint = " pixels per second in a Clear";
  53.     this->usecPrint = " microseconds per Clear";
  54.     this->ratePrint = " Clears per second";
  55.     /* Set virtual functions */
  56.     this->SetState = Clear__SetState;
  57.     this->delete = delete_Clear;
  58.     this->Initialize = Clear__Initialize;
  59.     this->Cleanup = Clear__Cleanup;
  60.     this->SetExecuteFunc = Clear__SetExecuteFunc;
  61.     this->Copy = Clear__Copy;
  62.     this->PixelSize = Clear__Size;
  63.     return this;
  64. }
  65.  
  66. void delete_Clear(TestPtr thisTest)
  67. {
  68.     ClearPtr this = (ClearPtr)thisTest;
  69.     delete_Drawn(thisTest);
  70. }
  71.  
  72. TestPtr Clear__Copy(TestPtr thisTest)
  73. {
  74.     ClearPtr this = (ClearPtr)thisTest;
  75.     ClearPtr newClear = new_Clear();
  76.     FreeStrings((TestPtr)newClear);
  77.     *newClear = *this;
  78.     CopyStrings((TestPtr)newClear, (TestPtr)this);
  79.     return (TestPtr)newClear;
  80. }
  81.  
  82. int Clear__SetState(TestPtr thisTest)
  83. {
  84.     ClearPtr this = (ClearPtr)thisTest;
  85.     if (Drawn__SetState(thisTest) == -1) return -1;
  86.     this->mask = (this->clearColor) ? GL_COLOR_BUFFER_BIT : 0;
  87.     this->mask |= (this->clearDepth) ? GL_DEPTH_BUFFER_BIT : 0;
  88.     this->mask |= (this->clearStencil) ? GL_STENCIL_BUFFER_BIT : 0;
  89.     this->mask |= (this->clearAccum) ? GL_ACCUM_BUFFER_BIT : 0;
  90.     if (this->environ.bufConfig.rgba) {
  91.         glColor3ub(0xff, 0xff, 0xff);
  92.         switch (this->colorOfClear) {
  93.             case Red:
  94.                 glClearColor(0xff, 0x00, 0x00, 0xff);
  95.                 break;
  96.             case Green:
  97.                 glClearColor(0x00, 0xff, 0x00, 0xff);
  98.                 break;
  99.             case Blue:
  100.                 glClearColor(0x00, 0x00, 0xff, 0xff);
  101.                 break;
  102.             case Magenta:
  103.                 glClearColor(0xff, 0x00, 0xff, 0xff);
  104.                 break;
  105.             case Cyan:
  106.                 glClearColor(0x00, 0xff, 0xff, 0xff);
  107.                 break;
  108.             case Yellow:
  109.                 glClearColor(0xff, 0xff, 0x00, 0xff);
  110.                 break;
  111.             case Grey:
  112.                 glClearColor(0xef, 0xef, 0xef, 0xff);
  113.                 break;
  114.             case White:
  115.                 glClearColor(0xff, 0xff, 0xff, 0xff);
  116.                 glColor3ub(0x00, 0x00, 0x00);
  117.                 break;
  118.             case Black:
  119.                 glClearColor(0x00, 0x00, 0x00, 0xff);
  120.                 break;
  121.         }
  122.     } else { /* CIVisual */
  123.         glClearIndex(this->clearIndex);
  124.     }
  125.     /* For clears only, set the scissor to base off of window size */
  126.     if (this->scissorTest) {
  127.         glScissor(10,10,this->environ.windowWidth-20,this->environ.windowHeight-20);
  128.     }
  129.     if (this->pointDraw) {
  130.         /* set projection matrix */
  131.         glMatrixMode(GL_PROJECTION);
  132.         glLoadIdentity();
  133.         glOrtho(-1.0,1.0,-1.0,1.0,0.5,10.0);
  134.         glMatrixMode(GL_MODELVIEW);
  135.         glLoadIdentity();
  136.     }
  137.     return 0;
  138. }
  139.  
  140. void Clear__Initialize(TestPtr thisTest)
  141. {
  142.     ClearPtr this = (ClearPtr)thisTest;
  143.     this->numObjects = 1;
  144. }
  145.  
  146. void Clear__Cleanup(TestPtr thisTest)
  147. {
  148.     ClearPtr this = (ClearPtr)thisTest;
  149. }
  150.  
  151. void Clear__SetExecuteFunc(TestPtr thisTest)
  152. {
  153.     ClearPtr this = (ClearPtr)thisTest;
  154.     ClearFunc function;
  155.  
  156.     function.word = 0;
  157.  
  158.     function.bits.pointDraw = this->pointDraw;
  159.     function.bits.functionPtrs = this->loopFuncPtrs;
  160.     function.bits.unrollAmount  = this->loopUnroll - 1;
  161.  
  162.     this->Execute = ClearExecuteTable[function.word];
  163. }
  164.  
  165. float Clear__Size(TestPtr thisTest)
  166. {
  167.     ClearPtr this = (ClearPtr)thisTest;
  168.     return (float)(this->environ.windowWidth * this->environ.windowHeight);
  169. }
  170.